{{ header }}
<script>
    $('header').hide();
</script>
<div id="product-product" class="containers" style="margin: 0 auto;padding: 0;">
    {#轮播#}
    <div id="goods-img-banner" class="swiper-container">
        <ul class="swiper-wrapper" style="list-style: none;padding: 0;">
            <li class="swiper-slide text-center">
                <a class="thumbnail goods-img" href="javascript:" title="{{ heading_title }}">
                    <img src="{{ popup }}" alt="{{ heading_title }}" class="img-responsive"/>
                </a>
            </li>
            {% for image in images %}
                <li class="swiper-slide text-center">
                    <a class="thumbnail goods-img" href="javascript:" title="{{ heading_title }}">
                        <img src="{{ image.popup }}" alt="{{ heading_title }}" class="img-responsive"/>
                    </a>
                </li>
            {% endfor %}
        </ul>
        <div class="swiper-pagination slideshow-point"></div>
    </div>
    <script type="text/javascript">
        $('#goods-img-banner').swiper({
            mode: 'horizontal',
            slidesPerView: 1,
            pagination: '.slideshow-point',
            paginationClickable: true,
            nextButton: '.swiper-button-next',
            prevButton: '.swiper-button-prev',
            spaceBetween: 30,
            autoplay: 2500,
            autoplayDisableOnInteraction: true,
            loop: true
        });
    </script>
    {#轮播 end#}
    <div class="goods-name">{{ heading_title }}</div>
    <div class="goods-price">
        {% if price %}
            <ul class="list-unstyled info-money">
                {% if not special %}
                    <li><span class="new-money">{{ price }}</span></li>
                {% else %}
                    <li><span class="new-money">{{ special }}</span></li>
                    <li><span class="old-money">{{ price }}</span></li>
                    {#<lis#}
                {% endif %}
                {#{% if tax %}#}
                {#<li>{{ text_tax }} {{ tax }}</li>#}
                {#<li>Save Off: {{ product.saveoff }}%</li>#}
                {#{% endif %}#}
                {#{% if points %}#}
                {#<li>{{ text_points }} {{ points }}</li>#}
                {#{% endif %}#}
                {#{% if discounts %}#}
                {#<li>#}
                {#<hr>#}
                {#</li>#}
                {#{% for discount in discounts %}#}
                {#<li>{{ discount.quantity }}{{ text_discount }}{{ discount.price }}</li>#}
                {#{% endfor %}#}
                {#{% endif %}#}
            </ul>
        {% endif %}
        <div class="goods-countdown" id="goodsCountdown">
            {#<span>今日限定</span><span class="kill-number">10</span><span>時</span><span class="kill-number">51</span><span>分</span><span class="kill-number">45</span>#}
        </div>
    </div>
    <ul class="commitment">
        <li><i class="fa fa-check-circle"></i>ฟรีค่าจัดส่ง</li>
        <li><i class="fa fa-check-circle"></i>ชำระเงินปลายทาง</li>
        <li><i class="fa fa-check-circle"></i>รับบัตรเครดิต</li>
        <li><i class="fa fa-check-circle"></i>บประกันคืนสินค้าภายใน 7 วัน</li>
    </ul>
    <ul class="goods-title">
        <li class="logo">
            <img src="https://www.vivishop.tw/skin/frontend/yisainuo/wap/images/logo.png" alt="">
        </li>
        <li class="goods-info">
            <a href="javascript:">{{ tab_attribute }}</a>
        </li>
        <li class="evaluation">
            <a href="javascript:">{{ tab_review }}</a>
        </li>
    </ul>
    <div class="tab-menu tab-content">
        <div class="tab-pane active" id="tab-description">{{ magevideo }}</div>
        <div class="tab-pane active" id="tab-review">
            <div class="review-header">
                <span>{{ tab_review }}</span>
                <a id="writeReview" href="javascript:">{{ text_write }}</a>
            </div>
            <ul id="review"></ul>
            <form class="form-horizontal" style="display: none" id="form-review">
                <div class="write-title">
                    {{ text_write }}
                    <i class="fa fa-times-circle"></i>
                </div>
                {% if review_guest %}
                    <div class="form-group required">
                        <div class="col-sm-12">
                            <label class="control-label" for="input-name">{{ entry_name }}</label>
                            <input type="text" name="name" value="{{ customer_name }}" id="input-name"
                                   class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group required">
                        <div class="col-sm-12">
                            <label class="control-label" for="input-review">{{ entry_review }}</label>
                            <textarea name="text" rows="5" id="input-review"
                                      class="form-control" style="resize: none"></textarea>
                            {#<div class="help-block">{{ text_note }}</div>#}
                        </div>
                    </div>
                    <div class="form-group required">
                        <div class="col-sm-12">
                            <label class="control-label">{{ entry_rating }}</label>
                            &nbsp;&nbsp;&nbsp; {{ entry_bad }}&nbsp;
                            <input type="radio" name="rating" value="1"/>
                            &nbsp;
                            <input type="radio" name="rating" value="2"/>
                            &nbsp;
                            <input type="radio" name="rating" value="3"/>
                            &nbsp;
                            <input type="radio" name="rating" value="4"/>
                            &nbsp;
                            <input type="radio" name="rating" value="5"/>
                            &nbsp;{{ entry_good }}</div>
                    </div>
                    {{ captcha }}
                    <div class="buttons clearfix">
                        <div class="pull-right">
                            <button type="button" id="button-review" data-loading-text="{{ text_loading }}"
                                    class="btn btn-primary">{{ button_continue }}</button>
                        </div>
                    </div>
                {% else %}
                    {{ text_login }}
                {% endif %}
            </form>
        </div>
    </div>
    <div class="goods-footer">
        <div style="flex: 1;"><a href="{{ home }}"><i class="fa fa-home"></i><span>หน้าแรก</span></a></div>
        {#<div style="flex: 1;"><i class="fa fa-commenting"></i><span>客服</span></div>#}
        <div style="flex: 1;"><a href="/checkout_cart.html"><i class="fa fa-shopping-cart"></i><span>รถเข็น</span></a>
        </div>
        <div class="buy-now" id="buyNow" style="flex: 3;">รีบซื้อเลย<i class="fa fa-chevron-right"></i></div>
    </div>
    <div id="product">
        {% if options %}
        <div class="buy-head">
            <img id="bigImg" src="{{ popup }}" alt="">
            <div class="buy-info">
                <div class="buy-price">
                    {% if not special %}
                        <span class="moneyNum">{{ price }}</span>
                    {% else %}
                        <span class="moneyNum">{{ special }}</span>
                    {% endif %}
                    <span style="margin-left: 10px;font-size: 14px;color: #c0c0c0;font-weight: normal;">จำนวน<span
                                style="font-size: 14px;color: #ce0067;padding: 0 5px;"
                                class="goodsCount">{{ minimum }}</span>ชิ้น</span>
                </div>
                <div class="buy-name">{{ heading_title }}</div>
            </div>
            <i id="closeBuy" class="fa fa-times"></i>
        </div>
        <div class="buy-spec">
            {% for option in options %}
                {% if option.type == 'select' %}
                    <div class="form-group{% if option.required %} required {% endif %}">
                        <label class="control-label"
                               for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
                        <ul id="input-options{{ option.product_option_id }}" class="select-box selectBox">
                            {% for option_value in option.product_option_value %}
                                {#{% if option.name=='顏色' %}#}
                                <li class="select-box-list color-list" data-img="{{ option_value.image }}"
                                    data-list-id="input-option{{ option.product_option_id }}"
                                    data-option-value="{{ option_value.product_option_value_id }}">
                                {#{% else %}#}
                                    {#<li class="select-box-list" data-img="{{ option_value.image }}" data-list-id="input-option{{ option.product_option_id }}" data-option-value="{{ option_value.product_option_value_id }}">#}
                                {#{% endif %}#}
                                {{ option_value.name }}
                                </li>
                            {% endfor %}
                        </ul>
                        <select name="option[{{ option.product_option_id }}]"
                                id="input-option{{ option.product_option_id }}" class="form-control hidden">
                            <option value="">{{ text_select }}</option>
                            {% for option_value in option.product_option_value %}
                                <option value="{{ option_value.product_option_value_id }}">{{ option_value.name }}
                                    {% if option_value.price %}
                                        ({{ option_value.price_prefix }}{{ option_value.price }})
                                    {% endif %} </option>
                            {% endfor %}
                        </select>
                    </div>
                {% endif %}
                {% if option.type == 'radio' %}
                    <div class="form-group{% if option.required %} required {% endif %}">
                        <label class="control-label">{{ option.name }}</label>
                        <div id="input-option{{ option.product_option_id }}"> {% for option_value in option.product_option_value %}
                                <div class="radio">
                                    <label>
                                        <input type="radio" name="option[{{ option.product_option_id }}]"
                                               value="{{ option_value.product_option_value_id }}"/>
                                        {% if option_value.image %} <img src="{{ option_value.image }}"
                                                                         alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}"
                                                                         class="img-thumbnail"/> {% endif %}
                                        {{ option_value.name }}
                                        {% if option_value.price %}
                                            ({{ option_value.price_prefix }}{{ option_value.price }})
                                        {% endif %} </label>
                                </div>
                            {% endfor %} </div>
                    </div>
                {% endif %}
                {% if option.type == 'checkbox' %}
                    <div class="form-group{% if option.required %} required {% endif %}">
                        <label class="control-label">{{ option.name }}</label>
                        <div id="input-option{{ option.product_option_id }}"> {% for option_value in option.product_option_value %}
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" name="option[{{ option.product_option_id }}][]"
                                               value="{{ option_value.product_option_value_id }}"/>
                                        {% if option_value.image %} <img src="{{ option_value.image }}"
                                                                         alt="{{ option_value.name }} {% if option_value.price %} {{ option_value.price_prefix }} {{ option_value.price }} {% endif %}"
                                                                         class="img-thumbnail"/> {% endif %}
                                        {{ option_value.name }}
                                        {% if option_value.price %}
                                            ({{ option_value.price_prefix }}{{ option_value.price }})
                                        {% endif %} </label>
                                </div>
                            {% endfor %} </div>
                    </div>
                {% endif %}
                {% if option.type == 'text' %}
                    <div class="form-group{% if option.required %} required {% endif %}">
                        <label class="control-label"
                               for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
                        <input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}"
                               placeholder="{{ option.name }}" id="input-option{{ option.product_option_id }}"
                               class="form-control"/>
                    </div>
                {% endif %}
                {% if option.type == 'textarea' %}
                    <div class="form-group{% if option.required %} required {% endif %}">
                        <label class="control-label"
                               for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
                        <textarea name="option[{{ option.product_option_id }}]" rows="5" placeholder="{{ option.name }}"
                                  id="input-option{{ option.product_option_id }}"
                                  class="form-control">{{ option.value }}</textarea>
                    </div>
                {% endif %}
                {% if option.type == 'file' %}
                    <div class="form-group{% if option.required %} required {% endif %}">
                        <label class="control-label">{{ option.name }}</label>
                        <button type="button" id="button-upload{{ option.product_option_id }}"
                                data-loading-text="{{ text_loading }}" class="btn btn-default btn-block"><i
                                    class="fa fa-upload"></i> {{ button_upload }}</button>
                        <input type="hidden" name="option[{{ option.product_option_id }}]" value=""
                               id="input-option{{ option.product_option_id }}"/>
                    </div>
                {% endif %}
                {% if option.type == 'date' %}
                    <div class="form-group{% if option.required %} required {% endif %}">
                        <label class="control-label"
                               for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
                        <div class="input-group date">
                            <input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}"
                                   data-date-format="YYYY-MM-DD" id="input-option{{ option.product_option_id }}"
                                   class="form-control"/>
                            <span class="input-group-btn">
                <button class="btn btn-default" type="button"><i class="fa fa-calendar"></i></button>
                </span></div>
                    </div>
                {% endif %}
                {% if option.type == 'datetime' %}
                    <div class="form-group{% if option.required %} required {% endif %}">
                        <label class="control-label"
                               for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
                        <div class="input-group datetime">
                            <input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}"
                                   data-date-format="YYYY-MM-DD HH:mm" id="input-option{{ option.product_option_id }}"
                                   class="form-control"/>
                            <span class="input-group-btn">
                <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
                </span></div>
                    </div>
                {% endif %}
                {% if option.type == 'time' %}
                    <div class="form-group{% if option.required %} required {% endif %}">
                        <label class="control-label"
                               for="input-option{{ option.product_option_id }}">{{ option.name }}</label>
                        <div class="input-group time">
                            <input type="text" name="option[{{ option.product_option_id }}]" value="{{ option.value }}"
                                   data-date-format="HH:mm" id="input-option{{ option.product_option_id }}"
                                   class="form-control"/>
                            <span class="input-group-btn">
                <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
                </span></div>
                    </div>
                {% endif %}
            {% endfor %}
            {% endif %}
            {% if recurrings %}
                <hr>
                <h3>{{ text_payment_recurring }}</h3>
                <div class="form-group required">
                    <select name="recurring_id" class="form-control">
                        <option value="">{{ text_select }}</option>
                        {% for recurring in recurrings %}
                            <option value="{{ recurring.recurring_id }}">{{ recurring.name }}</option>
                        {% endfor %}
                    </select>
                    <div class="help-block" id="recurring-description"></div>
                </div>
            {% endif %}
        </div>
        <div id="inputNumBox" class="input-num-box">
            <div class="calculate" style="display: none">
                <span id="input2" class="reduce action calculate-child">-</span>
                <input type="text" name="quantity" value="{{ minimum }}" size="2" id="input-quantity"
                       class="form-control calculate-child"/>
                <span id="input1" class="pus action calculate-child">+</span>
                <input type="hidden" name="product_id" value="{{ product_id }}"/>
                <input type="hidden" id="product_stock" value="{{ stockch }}"/>
            </div>
            {#<button type="button" id="button-cart" data-loading-text="{{ text_loading }}" class="btn btn-primary btn-lg btn-block">{{ button_cart }}</button>#}
            <button type="button" id="button-cart" data-loading-text="{{ text_loading }}" class="add-to-cart">รีบซื้อเลย<i
                        class="fa fa-chevron-right"></i></button>
        </div>
        {% if minimum > 1 %}
            <div class="alert alert-info"><i class="fa fa-info-circle"></i> {{ text_minimum }}</div>
        {% endif %}
    </div>
    <div id="productMask"></div>
    <input type="hidden" value="{{ date_end }}" id="date_end">
    <input type="hidden" value="{{ date_now }}" id="date_now">
</div>
<script>
    // 是否有规格
    var noProduct = false;
    $(function () {
        goodsCountdown($('#date_now').val(), $('#date_end').val());
        $('.goods-title').removeClass('position-fixed');
        buyBug();
    });
    // 修复没有规格购买按钮乱跑
    function buyBug() {
        if($('#product').html().replace(/(^\s*)|(\s*$)/g, "") == ''){
            $('#product').append($('#inputNumBox'));
            noProduct = true;
        }
    }

    // 倒计时
    function goodsCountdown(startTime, endTime) {
        var allTime = endTime - startTime;
        var timer = setInterval(function () {
            if (allTime <= 0) {
                $('#goodsCountdown').empty();
                clearInterval(timer);
                return false;
            }
            var tag = '<span>จำกัดเวลา</span><span class="kill-number">' + Math.floor(allTime / 3600) + '</span><span>นาฬิกา</span><span class="kill-number">' + Math.floor((allTime % 3600) / 60) + '</span><span>นาที</span><span class="kill-number">' + (allTime % 3600) % 60 + '</span>';
            $('#goodsCountdown').html(tag);
            allTime--;
        }, 1000)
    }

    // 吸頂
    var goodsTitleTop = $('.goods-title')[0].offsetTop;
    window.onscroll = function () {
        if ($(window).scrollTop() >= $('#tab-description')[0].offsetTop - 42) {
            $('.goods-title').addClass('position-fixed');
            $('#tab-description')[0].style.marginTop = '42px';
        } else {
            $('.goods-title').removeClass('position-fixed');
            $('#tab-description')[0].style.marginTop = 0;
        }
    };
    // 點擊商品介紹和客戶評價
    $('.goods-info').on('click', function () {
        $('html,body').stop().animate({scrollTop: $('#tab-description')[0].offsetTop - 42}, 500);
    });
    $('.evaluation').on('click', function () {
        $('html,body').stop().animate({scrollTop: $('#tab-review')[0].offsetTop - 42}, 500);
    });
    // 我要評論
    $('#writeReview').on('click', function () {
        $('#productMask').stop().fadeIn(300);
        $('#form-review').show();
        $('body')[0].style.overflow = 'hidden';
    });
    $('#form-review>.write-title>i').on('click', function () {
        $('#productMask').stop().fadeOut(300);
        $('#form-review').hide();
        $('body')[0].style.overflow = 'auto';
    });
    // 立即购买
    $('#buyNow').on('click', function () {
        if(noProduct){
            $('#button-cart').click();
            return;
        }
        $('#productMask').stop().fadeIn(300);
        $('#product').stop().slideDown(100);
        $('body')[0].style.overflow = 'hidden';
    });
    $('#closeBuy').on('click', closeBuy);
    function closeBuy() {
        $('#productMask').stop().fadeOut(300);
        $('#product').stop().slideUp(100);
        $('body')[0].style.overflow = 'auto';
    }
    // 選擇規格
    $('.selectBox .color-list').on('click', function () {
        $('#bigImg').attr('src', $(this)[0].dataset.img);
    });
    $('.selectBox .select-box-list').on('click', function () {
        $(this).addClass('selected-list').siblings().removeClass('selected-list');
        $('select#' + $(this)[0].dataset.listId).val($(this)[0].dataset.optionValue);
    });
</script>
<script type="text/javascript"><!--
    $('select[name=\'recurring_id\'], input[name="quantity"]').change(function () {
        $.ajax({
            url: 'index.php?route=product/product/getRecurringDescription',
            type: 'post',
            data: $('input[name=\'product_id\'], input[name=\'quantity\'], select[name=\'recurring_id\']'),
            dataType: 'json',
            beforeSend: function () {
                $('#recurring-description').html('');
            },
            success: function (json) {
                $('.alert-dismissible, .text-danger').remove();

                if (json['success']) {
                    $('#recurring-description').html(json['success']);
                }
            }
        });
    });
    //--></script>
<script>
    //商品数量的增加
    var goodsCount = document.getElementById('input-quantity');             // 数字
    var plusBtn = document.getElementById('input1');                        // 加号
    var minusBtn = document.getElementById('input2');                       // 减号
    var goodsStock = document.getElementById('product_stock').value;        // 库存
    var onePrice = $('.buy-price .moneyNum').text()[0] === '$' ? $('.buy-price .moneyNum').text().slice(1, $('.buy-price .moneyNum').text().length - 1) : $('.buy-price .moneyNum').text();
    plusBtn.onclick = function () {
        if (goodsCount.value >= goodsStock) {
            alert('庫存不足！');
            return;
        }
        goodsCount.value++;
        $('.goodsCount').text(goodsCount.value);
        $('.buy-price .moneyNum').text('$' + (goodsCount.value * onePrice).toFixed(2));
    };
    minusBtn.onclick = function () {
        if (goodsCount.value > 1) {
            goodsCount.value--;
            $('.goodsCount').text(goodsCount.value);
            $('.buy-price .moneyNum').text('$' + (goodsCount.value * onePrice).toFixed(2));
        }
    }
</script>
<script type="text/javascript"><!--
    $('#button-cart').on('click', function () {
        $.ajax({
            url: 'index.php?route=checkout/cart/add',
            type: 'post',
            data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
            dataType: 'json',
            beforeSend: function () {
                $('#button-cart').button('loading');
            },
            complete: function () {
                $('#button-cart').button('reset');
            },
            success: function (json) {
                $('.alert-dismissible, .text-danger').remove();
                $('.form-group').removeClass('has-error');
                if (json['error']) {

                    if (json['error']['option']) {
                        for (i in json['error']['option']) {
                            var element = $('#input-option' + i.replace('_', '-'));

                            if (element.parent().hasClass('input-group')) {
                                element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
                            } else {
                                element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
                            }
                        }
                    }

                    if (json['error']['recurring']) {
                        $('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
                    }

                    // Highlight any found errors
                    $('.text-danger').parent().addClass('has-error');
                }


                if (json['success']) {
                    //$('.breadcrumb').after('<div class="alert alert-success alert-dismissible">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');

                    //$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');

                    //$('html, body').animate({ scrollTop: 0 }, 'slow');
                    window.location.href = "checkout_cart.html";
                    //$('#cart > ul').load('index.php?route=common/cart/info ul li');
                }

                if(json['error']['hasadd']){
                    alert(json['error']['hasadd']);
                    closeBuy();
                }
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
            }
        });
    });
    //--></script>
<script type="text/javascript"><!--
    $('.date').datetimepicker({
        language: '{{ datepicker }}',
        pickTime: false
    });

    $('.datetime').datetimepicker({
        language: '{{ datepicker }}',
        pickDate: true,
        pickTime: true
    });

    $('.time').datetimepicker({
        language: '{{ datepicker }}',
        pickDate: false
    });

    $('button[id^=\'button-upload\']').on('click', function () {
        var node = this;

        $('#form-upload').remove();

        $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');

        $('#form-upload input[name=\'file\']').trigger('click');

        if (typeof timer != 'undefined') {
            clearInterval(timer);
        }

        timer = setInterval(function () {
            if ($('#form-upload input[name=\'file\']').val() != '') {
                clearInterval(timer);

                $.ajax({
                    url: 'index.php?route=tool/upload',
                    type: 'post',
                    dataType: 'json',
                    data: new FormData($('#form-upload')[0]),
                    cache: false,
                    contentType: false,
                    processData: false,
                    beforeSend: function () {
                        $(node).button('loading');
                    },
                    complete: function () {
                        $(node).button('reset');
                    },
                    success: function (json) {
                        $('.text-danger').remove();

                        if (json['error']) {
                            $(node).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>');
                        }

                        if (json['success']) {
                            alert(json['success']);

                            $(node).parent().find('input').val(json['code']);
                        }
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                });
            }
        }, 500);
    });
    //--></script>
<script type="text/javascript"><!--
    $('#review').delegate('.pagination a', 'click', function (e) {
        e.preventDefault();

        $('#review').fadeOut('slow');

        $('#review').load(this.href);

        $('#review').fadeIn('slow');
    });

    $('#review').load('index.php?route=product/product/review&product_id={{ product_id }}');

    $('#button-review').on('click', function () {
        $.ajax({
            url: 'index.php?route=product/product/write&product_id={{ product_id }}',
            type: 'post',
            dataType: 'json',
            data: $("#form-review").serialize(),
            beforeSend: function () {
                $('#button-review').button('loading');
            },
            complete: function () {
                $('#button-review').button('reset');
            },
            success: function (json) {
                $('.alert-dismissible').remove();

                if (json['error']) {
                    $('#review').after('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
                }

                if (json['success']) {
                    $('#review').after('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');

                    $('input[name=\'name\']').val('');
                    $('textarea[name=\'text\']').val('');
                    $('input[name=\'rating\']:checked').prop('checked', false);
                }
                $('#productMask').stop().fadeOut(300);
                $('#form-review').hide();
                $('body')[0].style.overflow = 'auto';
            }
        });
    });

    $(document).ready(function () {
        $('.thumbnails').magnificPopup({
            type: 'image',
            delegate: 'a',
            gallery: {
                enabled: true
            }
        });
    });
    //--></script>
{{ footer }} 
